import { IFeidaoAiBrowserComponent } from "@feidao/web/interfaces";
import { anim, play } from '@feidao/animation';
import local_set from '@feidao/web/atom/browser/local/set';
import local_get from '@feidao/web/atom/browser/local/get';
export default async function (fd: IFeidaoAiBrowserComponent, ...args: any[]) {
	const left = fd.data.node.querySelector<HTMLDivElement>('[lefts="lefts"]')
	const right = document.getElementById('right');
	const lefts = await local_get(fd, 'lefts');
	const target = args[0].currentTarget as HTMLImageElement;
	if (lefts) {
		play(anim(left, {}, { left: { start: -180, end: 0 } }));
		play(anim(right, {}, { left: { start: 0, end: 180 } }));
		await local_set(fd, 'lefts', false);
		target.src = 'images/jt_but.png';
	} else {
		play(anim(left, {}, { left: { start: 0, end: -180 } }));
		play(anim(right, {}, { left: { start: 180, end: 0 } }));
		await local_set(fd, 'lefts', true);
		target.src = 'images/jt_but1.png';
	}
}